package com.demo.component.task;

import com.demo.component.bean.RedisUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 定时任务
 */
@Component
@EnableScheduling
public class TestSchedule {

    @Autowired
    private RedisUtils redisUtils;

    @Scheduled(fixedDelay = 2000)
    public void execute() {
        Integer data = redisUtils.get("test");
        if (data != null) {
            System.out.println(data);
        } else {
            System.out.println("redis中没有key为test的值");
        }
        redisUtils.incr("test", 60);
    }
}
